package com.biyeshengjiuye.service.impl;

import com.biyeshengjiuye.dao.StudentMapper;
import com.biyeshengjiuye.entity.Student;
import com.biyeshengjiuye.service.StudentService;
import com.biyeshengjiuye.utils.PasswordUtil;
import com.biyeshengjiuye.utils.SystemConstant;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
@Service
@Transactional
public class StudentServiceImpl implements StudentService {


    @Resource
    private StudentMapper studentMapper;

    public Student login(String loginId, String loginPwd) {
        Student student = studentMapper.findStudentById(loginId);
        if (student != null){
            String newPassword = PasswordUtil.md5(loginPwd,loginId, SystemConstant.PASSWORD_COUNT);
            if (student.getStu_password().equals(newPassword)){
                return student;
            }
        }
        return null;
    }
}
